{extend name="layout/base"/}
{block name="content"}
{load href="__BKD__/js/dataLoader.js"/}
<div class="page-title">
    <h3 class="ui header"> 录入分数</h3>
</div>
<div style="overflow: scroll; width: 100%; height: calc(100vh-70px); box-sizing: border-box; padding: 10px 0;">
    <table class="ui definition striped unstackable table">
        <thead>
        <tr>
            <th></th>
            {volist name="questions" id="v"}
            <th valign="top" style="font-weight: normal; font-size: 80%;">
                {$key}.{$v} <br>【答案：{$answers[$key]}】
            </th>
            {/volist}
        </tr>
        </thead>
        <tbody>
        {volist name="names" id="s"}
        <tr>
            <td class="collapsing">{$key}{$s}</td>
            {volist name="inputs[$key]" id="v"}
            <td>
                {switch name="type"}
                {case value="0"}
                <div style="display: inline-block;">
                    <div class="ui radio checkbox">
                        <input type="radio" class="question-radio" name="radio{$v.student_id}-{$v.test_id}-{$v.question_id}" value="1" data-id="{$v.student_id}-{$v.test_id}-{$v.question_id}-{$type}" {gt name="v.is_right" value="1"}checked="checked"{/gt}>
                        <label>对</label>
                    </div>
                </div>
                <div style="display: inline-block;">
                    <div class="ui radio checkbox">
                        <input type="radio" class="question-radio" name="radio{$v.student_id}-{$v.test_id}-{$v.question_id}" value="-1" data-id="{$v.student_id}-{$v.test_id}-{$v.question_id}-{$type}" {eq name="v.is_right" value="-1"}checked="checked"{/eq}>
                        <label>错</label>
                    </div>
                </div>
                {/case}
                {case value="1"}
                <input value="{$v.answer??''}" data-id="{$v.student_id}-{$v.test_id}-{$v.question_id}-{$type}" placeholder="第{$key}题答案" class="edit-input center aligned" style="border:none;padding: 3px"/>
                {/case}
                {case value="2"}
                <input value="{$v.score??''}" data-id="{$v.student_id}-{$v.test_id}-{$v.question_id}-{$type}" placeholder="第{$key}题分数" class="edit-input center aligned" style="border:none;padding: 3px"/>
                {/case}
                {/switch}

            </td>
            {/volist}
        </tr>
        {/volist}
        </tbody>
    </table>
</div>
{/block}
{block name="script"}
<script>
    $(function(){
        $('.edit-input').change(function(){
            var v = $(this).val(),
              code = $(this).data('id');
            ajaxRequest('{:url("saveScore")}', {code: code, value: v}, function(res) {
                if(res.code == 1) {
                    layer.msg(res.msg,{time:1000});
                }
            });
        });
        $('.question-radio').change(function(){
            var v = $(this).val(),
                code = $(this).data('id');
                // console.log(v);
                // console.log(code);
            ajaxRequest('{:url("saveScore")}', {code: code, value: v}, function(res) {
                if(res.code == 1) {
                    layer.msg(res.msg,{time:1000});
                }
            });
        });
    });
</script>
{/block}